/* ====================================== 异步加载路由组件  ====================================== */
import React, { Component } from 'react'
// ===================================================================== loadding 
import PageLoading from '@tp/page-loading'
// ===================================================================== 
const Lazy = importComponent => {
	
	return class extends Component {
		
	   	state = {
	   		Component: () => <PageLoading/>
	   	}
	
	    async componentDidMount() {
			
			// importComponent().then(f => this.setState({ Component: f.default } ) )
			
			const { default: Component } = await importComponent(); this.setState({ Component })
	    }
	    
	    render() {
			
	        const { Component } = this.state
	
	        return Component ? <Component {...this.props} /> : null
			
	    }
	}
}

const Index = path => Lazy(() => import('@views/' + path))

export default Index